package simtester.server

import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.web.ControllerUnitTestMixin} for usage instructions
 */
@TestFor(UserController)
@Mock([User,TestCase,Team])
class UserControllerTests {

    @Before
    void setUp() {
        
    }
    
    @Test
    void newUserComesWithDefaultTestCase() {
        def testuser = 'someuser'
        def teamName = 'svt'
        
        new Team(name: teamName).save()
        
        request.method = 'POST'
        params.username = testuser
        params.password = 'someuser'
        params.password_confirmation = 'someuser'
        params.team = teamName
        controller.register()
        
        def u = User.findByUsername(testuser)
        def tc = TestCase.findByOwner(u)
        assert tc.name == 'DefaultGoogleTest'
        assert tc.script
        assert tc.team.name == teamName
    }
}
